<?php
	namespace Mall\Model;
	use Common\Model\BaseModel;
	class VoucherModel extends BaseModel{

		protected  $_auto =[
			['create_time','time',1,'function'],
			['status',0,1]
		];

		public $_scope = [
			['valid'=>[
				'where'=>['is_closed'=>0,'audit'=>1,'delete_at'=>0]]
			],
		];

		public function _after_select(&$records,$option){
		$user = get_user();
			foreach($records as &$record)
			{
				$cate_name = D('GoodsCate')->where(['cate_id'=>$record['cate_id']])->getField('cate_name');
				$shop_name = D('Shop')->where(['shop_id'=>$record['shop_id']])->getField('shop_name');
				$record['cate_name'] = $cate_name;
				$record['shop_name'] = $shop_name;
			}

		}
	}